package com.junhong.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.junhong.dao.UserDao;
import com.junhong.entity.User;
import com.junhong.service.UserService;

@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {

	@Resource
	private UserDao userDao;
	
	@Override
	public void add(User user) {
		userDao.add(user);
	}

	@Override
	public void update(User user) {
		userDao.update(user);
	}

	@Override
	public void delete(User user) {
		userDao.delete(user);
	}

	@Override
	public List<User> find() {
		return userDao.find();
	}

	@Override
	public User getById(Serializable id) {
		return userDao.getById(id);
	}

	@Override
	public long count() {
		return userDao.count();
	}

	@Override
	public boolean loginUser(User user) {
		List<User>users =  userDao.loginUser(user);
		if(users.size()==0)
			return false;
		if(users.size()==1)
			return true;
		else {
			
			return false;
		}
	}

	@Override
	public User existUserWithUserName(String userName) {
		return (User) userDao.existUserWithUserName(userName);
	}

	@Override
	public User existUserWithRoleId(Integer roleId) {
		return (User) userDao.existUserWithRoleId(roleId);
	}

	@Override
	public List<User> find(Integer pos, Integer rows) {
		return userDao.find(pos, rows);
	}

}
